package chess

import (
	"sync"
	"time"

	"gddgame.cc/galaxy/asteroid/cluster"
	"gddgame.cc/galaxy/common/feature/orbit"
	"gddgame.cc/galaxy/satellite/formula/comet"
)

var (
	clientPool = sync.Pool{}
)

func init() {
	clientPool.New = func() interface{} {
		c := &Client{
			// 最大长度要小于一个Mut：200字节，也就是一条数据15-20字节
			NoticeBatch: *orbit.NewBatch(12),
		}
		c.init()
		return c
	}
}

type Client struct {
	*comet.Socket

	Identity int

	FrameRate time.Duration
	Size      *orbit.Location
	MapId     string
	Level     orbit.Point
	InitLevel bool

	NoticeBatch orbit.Batch
}

func NewClient() *Client {
	c := clientPool.Get().(*Client)

	return c
}
func (c *Client) Bind(socket *comet.Socket) {
	c.Socket = socket
}
func (c *Client) init() {
	c.NoticeBatch.Init()
}

func (c *Client) Release() {
	c.Socket = nil
	c.init()
	clientPool.Put(c)
}

func (c *Client) GetFrameRate() time.Duration {
	return c.FrameRate
}

func (c *Client) Dispatch(container cluster.Container, event comet.DE, packet comet.Packet) {

}
